<?php

namespace app\common\model\user;

use app\common\model\User;
use think\Model;


class PerkGrant extends Model
{

    

    

    // 表名
    protected $name = 'user_perk_grant';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];
    public function getTypeDataList()
    {
        return ['0' => __('Type_data 0'), '1' => __('Type_data 1')];
    }

    public function getTypeDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type_data']) ? $data['type_data'] : '');
        $list = $this->getTypeDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }
    public function getEnzdAttr($value, $data)
    {
        $enzdArr =User::where("id", "in", $data["user_ids"]) ->column('nickname');
        return implode(",", $enzdArr);
    }
}
